﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.Singleton
{
    /// <summary>
    /// 简单的单例，对外不公开上下文的写和删除方法
    /// </summary>
    public class Singleton
    {
        public List<string> StrContext { get; private set; }

        public void Add(string data)
        {
            StrContext.Add(data);
        }

        public void Remove(string data)
        {
            StrContext.Remove(data);
        }

        static Singleton instance;
        public static Singleton Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Singleton();
                    instance.StrContext = new List<string>();
                }
                return instance;
            }
        }
    }
}
